<?php


namespace app\api\controller\v1;


use app\api\model\Theme as ThemeModel;
use app\api\validate\IDCollection;
use app\api\validate\IDMustBePositiveInt;
use app\BaseController;
use app\lib\exception\ThemeException;
use think\Exception;
use think\exception\FileException;
use think\exception\ValidateException;
use think\facade\Validate;

class Theme extends BaseController
{
    public function getSimpleList($ids = '')
    {
        $ids = explode(',', $ids);
        (new IDCollection())->goCheck();
        $result = ThemeModel::with(['topicImg', 'headImg'])->select($ids);
        if ($result->isEmpty()) {
            throw new ThemeException();
        }
        return $result;
    }


    public function getComplexOne($id)
    {
        (new IDMustBePositiveInt())->goCheck();
        $theme = ThemeModel::getThemeWithProducts($id);
        if ($theme->isEmpty()) {
            throw new ThemeException();
        }
        return $theme;
    }
}